module.exports = {
  /*
   ** Headers of the page
   */
  head: {
    title: 'nuxt',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      {
        name: 'keywords',
        content: '卢忠宽,个人博客,luzhongkuan.cn,luzhongkuan,,前端开发,html,css,js,react,vue,node,小程序'
      },
      {
        hid: 'description', name: 'description',
        content: '卢忠宽,个人博客,luzhongkuan.cn,luzhongkuan,,前端开发,html,css,js,react,vue,node,小程序'
      }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },
  css: [
    '~/assets/style/reset.css',
    { src: '~assets/style/main.scss', lang: 'scss' }
  ],
  /*
   ** Customize the progress bar color
   */
  loading: { color: '#3B8070' },
  /*
   ** Build configuration
   */
  render: {
    bundleRenderer: {
      shouldPreload: (file, type) => {
        return ['script', 'style', 'font'].includes(type)
      },
      cache: require('lru-cache')({
        max: 1000,
        maxAge: 1000 * 60 * 15
      })
    }
  },
  router: {
    middleware: ['visits', 'user-agent']
  },
  build: {
    /*
     ** Run ESLint on save
     */
    vendor: ['axios'],
    postcss: [
      require('postcss-nested')(),
      require('postcss-responsive-type')(),
      require('postcss-hexrgba')()
    ],
    extend(config, { isDev, isClient }) {
      if (isDev && isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
      const vueLoader = config.module.rules.find((rule) => rule.loader === 'vue-loader')
      vueLoader.options.loaders.sass = 'vue-style-loader!css-loader!sass-loader'
    }
  }
}
